<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件</title>
</head>
<body>
    <span id="spanNode" onclick="handlerSearch()">百度一下</span>
    <script>
       function handlerSearch() {
           console.log("百度一下...............");
       }
       
       window.onkeyup = function(e) {
          if(e.keyCode === 13) {
            // handlerSearch()
            spanNode.click(); // 触发该节点的点击事件。。。
          }
       }

        // window.onkeydown = function(e) {
        //     console.log(e.keyCode);
        //     console.log("1.键盘按下。。。");
        // }
        // window.onkeyup = function(e) {
        //     console.log("3.键盘抬起。。。");
        // }
        // window.onkeypress = function(e) {
        //     console.log("2.按下并抬起....");
        // }
    </script>
</body>
</html>